Skip to content

Start V2/V3 migration. #1312 - #1413

Open
Lokowandtg wants to merge 5 commits into
cloudfoundry:mainfrom
Lokowandtg:main
Open

Lokowandtg wants to merge 5 commits into
cloudfoundry:mainfrom
Lokowandtg:main

Conversation

@Lokowandtg

Copy link
Copy Markdown
Contributor

Done with support of Claude AI.

This huge task will be done in many small commits hoping this will simplify the review.
Merge only when all changes are done.

Here a bunch of low risk (only integration-test) changes.

ApplicationUtils.java: The creation of a new Application
is more effort, as the V3 API gives more controll, which
results in more steps.

  • applicationsV2().create() - replaced with applicationsV3().create() using ApplicationRelationships
  • applicationsV2().upload() - replaced with a two-step packages().create() + packages().upload()
  • applicationsV2().get() + ResourceUtils.getEntity().getPackageState() - replaced with polling packages().get() until PackageState.READY
  • applicationsV2().update(env + state=STARTED) - replaced with applicationsV3().updateEnvironmentVariables() + applicationsV3().start()
  • applicationsV2().instances() + ApplicationInstanceInfo.getState() - replaced with applicationsV3().getProcessStatistics(type="web") polling ProcessState.RUNNING
  • applicationsV2().associateRoute() - replaced with routesV3().insertDestinations()

CloudFoundryCleaner.java: So far only the "simple" changes.

  • organizationQuotaDefinitions() replaced by organizationQuotasV3() Return value is now a mono, handled by flatMap.
  • organizations() replaced by organizationsV3()
  • securityGroups() replaced by securityGroupsV3(), return value is now a job that is polled.
  • serviceBrokers() replaced by serviceBrokersV3(), return value is now a job that is polled.
  • spaceQuotaDefinitions() replaced by spaceQuotasV3()
  • spaces() replaced by spacesV3(), parameter "recursive(true)" and "async" is the fixed behaviour in V3.
  • stacks() replaced by stacksV3() polling is no longer needed as no job is returned.

IntegrationTestConfiguration.java: mostly straightforward.

ServiceBrokerUtils.java: mostly straightforward.

Done with support of Claude AI.

This huge task will be done in many small commits hoping
this will simplify the review.

Here a bunch of low risk (only integration-test) changes.

ApplicationUtils.java: The creation of a new Application
  is more effort, as the V3 API gives more controll, which
  results in more steps.
  - applicationsV2().create() - replaced with applicationsV3().create() using ApplicationRelationships
  - applicationsV2().upload() - replaced with a two-step packages().create() + packages().upload()
  - applicationsV2().get() + ResourceUtils.getEntity().getPackageState() - replaced with polling packages().get() until PackageState.READY
  - applicationsV2().update(env + state=STARTED) - replaced with applicationsV3().updateEnvironmentVariables() + applicationsV3().start()
  - applicationsV2().instances() + ApplicationInstanceInfo.getState() - replaced with applicationsV3().getProcessStatistics(type="web") polling ProcessState.RUNNING
  - applicationsV2().associateRoute() - replaced with routesV3().insertDestinations()

CloudFoundryCleaner.java: So far only the "simple" changes.
  - organizationQuotaDefinitions()	replaced by  organizationQuotasV3()	Return value is now a mono, handled by flatMap.
  - organizations()	replaced by organizationsV3()
  - securityGroups() replaced by securityGroupsV3(), return value is now a job that is polled.
  - serviceBrokers() replaced by serviceBrokersV3(), return value is now a job that is polled.
  - spaceQuotaDefinitions() replaced by spaceQuotasV3()
  - spaces() replaced by spacesV3(), parameter "recursive(true)" and "async" is the fixed behaviour in V3.
  - stacks() replaced by stacksV3() polling is no longer needed as no job is returned.

IntegrationTestConfiguration.java: mostly straightforward.

ServiceBrokerUtils.java: mostly straightforward.
feat: Update the used JDK version (cloudfoundry#1407)
integration-test/src/test/java/org/cloudfoundry/ServiceBrokerUtils.java
  - requestCreateServiceBroker: V2 flat fields --> V3 BasicAuthentication + ServiceBrokerRelationships with space relationship; returns Mono<String> (job ID) instead of Mono<CreateServiceBrokerResponse>
  - Both createServiceBroker and createServiceBrokerNonPublic: the job ID is polled via JobUtils.waitForCompletion(...), then requestGetServiceBrokerId lists brokers by name to resolve the final broker ID - replacing the old ResourceUtils.getId(response) pattern
  - New requestGetServiceBrokerId helper: lists serviceBrokersV3() filtered by name, returns the single result's ID

integration-test/src/test/java/org/cloudfoundry/client/v3/IsolationSegmentsTest.java
  mostly simple replacements.
  requestCreateSpace: .spaces().create(CreateSpaceRequest.builder().name().organizationId()) --> .spacesV3().create(...) with SpaceRelationships / ToOneRelationship / Relationship builder chain

integration-test/src/test/java/org/cloudfoundry/networking/v1/PoliciesTest.java
  - requestCreateApplication: .applicationsV2().create(...) with V2 flat fields (buildpack, diego, diskQuota, memory, spaceId) --> .applicationsV3().create(...) with ApplicationRelationships/ToOneRelationship/Relationship builder chain
  - diego(true) removed - In V2, apps could run on the old DEA runtime or the newer Diego runtime. Diego became the only runtime long before V3 existed, so V3 has no such flag - all apps are Diego apps.
  - buildpack(..) removed - V3 separates the build configuration from the app itself. Buildpacks are specified on the build, not on the app create. The test only needs a CF resources with a GUID so the networking policy can reference it by ID.
  - diskQuota / memory removed - V3 sets resource limits on processes (via process scale), not on app creation. Again irrelevant here since the apps are never started.

integration-test/src/test/java/org/cloudfoundry/networking/v1/TagsTest.java:
  The changes are identical to PoliciesTest.

integration-test/src/test/java/org/cloudfoundry/operations/NetworkPoliciesTest.java:
  Same changes as PoliciesTest and TagsTest.

integration-test/src/test/java/org/cloudfoundry/operations/ServiceAdminTest.java
  - requestCreateSpace: .spaces() with flat organizationId --> .spacesV3() with SpaceRelationships/ToOneRelationship/Relationship builder chain

integration-test/src/test/java/org/cloudfoundry/operations/ServicesTest.java
  mostly simple replacements.

integration-test/src/test/java/org/cloudfoundry/operations/UserAdminTest.java
  mostly simple replacements.
  - getOrganizationId: organizations().list() + requestClientV2Resources + post-filter + ResourceUtils::getId --> organizationsV3().list(name=organizationName) + requestClientV3Resources + OrganizationResource::getId
  - requestListOrganizationAuditors: single-step V2 organizations().listAuditors() returning UserResource --> two-step V3: rolesV3().list(organizationId, type=ORGANIZATION_AUDITOR) --> flatMap each role's user ID to usersV3().get(), returning
    GetUserResponse

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant